<!--本文件由FirstUI授权予郝宁宁（手机号：15  5 1   24 698 1  2，身份证尾号： 05  0 51 3）专用，请尊重知识产权，勿私下传播，违者追究法律责任。-->
<template>
	<view class="fui-wrap">
		<view class="fui-page__hd">
			<view class="fui-page__title">Lottie</view>
			<view class="fui-page__desc">Lottie 动画，通过读取json文件信息实现动画效果。</view>
		</view>
		<view class="fui-page__bd fui-page__spacing">
			<view class="fui-section__title">本地json文件</view>
			<view class="fui-flex__center">
				<!-- 百度小程序平台path属性目前不支持远程地址，仅支持本地绝对路径 -->
				<!-- #ifdef MP-BAIDU -->
				<animation-view class="fui-animation" path="/static/json/nodata.json" loop :action="action"></animation-view>
				<!-- #endif -->

				<!-- #ifndef MP-BAIDU -->
				<fui-lottie :options="options"></fui-lottie>
				<!-- #endif -->
			</view>
			<!-- #ifndef MP-BAIDU -->
			<view class="fui-section__title">网络地址</view>
			<view class="fui-flex__center">
				<fui-lottie :options="option" :action="action"></fui-lottie>
			</view>
			<!-- #endif -->

			<view class="fui-flex__center fui-flex__column">
				<fui-button type="gray" btn-size="medium" text="暂停播放" bold :margin="['24rpx']"
					@click="ani('pause')"></fui-button>
				<fui-button type="gray" btn-size="medium" text="开始播放" bold @click="ani('play')">
				</fui-button>
				<fui-button type="gray" btn-size="medium" text="停止播放" bold :margin="['24rpx']"
					@click="ani('stop')">
				</fui-button>
			</view>

		</view>
	</view>
</template>

<script>
	import emptyJson from '@/static/json/nodata.json'
	export default {
		data() {
			return {
				options: {
					animationData: emptyJson
				},
				option: {
					path: 'https://res.firstui.cn/static/json/empty.json'
				},
				action: 'play'
			}
		},
		methods: {
			//销毁隐藏可使用v-if自行控制
			ani(action) {
				if (this.action === action) return;
				this.action = action
			}
		}
	}
</script>

<style>
	page {
		font-weight: normal;
	}
	.fui-animation{
		width: 400rpx;
		height: 400rpx;
	}
</style>